From 6f791165b79f20dece230d390d4c2ad4708526e0 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Fri, 24 Jun 2011 23:01:49 +0000 Subject: [PATCH] Directionality improvements as part of bug 6100 (under $wgBetterDirectionality): * Add CSS that should fix all LTR/LTR text on both LTR/RTL wikis, for the editsection link, TOC, and lists (ul/ol). * Add a class mw-content-ltr/rtl for that. * Change the divs on CategoryPage so it works wit that CSS. This is the last relatively major issue for bug 6100. --- includes/CategoryPage.php | 12 ++++++++---- includes/EditPage.php | 3 ++- includes/ImagePage.php | 3 ++- includes/SkinTemplate.php | 3 ++- skins/common/shared.css | 40 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 989e9e9b12..6843b82c4d 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -179,10 +179,13 @@ class CategoryViewer { $r = wfMsgExt( 'category-empty', array( 'parse' ) ); } - global $wgBetterDirectionality, $wgLang; + global $wgBetterDirectionality, $wgTitle; if( $wgBetterDirectionality ) { - $langAttribs = array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ); - $r = Html::rawElement( 'div', $langAttribs, $r ); + $pageLang = $wgTitle->getPageLanguage(); + $langAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); + # close the previous div, show the headings in user language, + # then open a new div with the page content language again + $r = '' . $r . Html::openElement( 'div', $langAttribs ); } wfProfileOut( __METHOD__ ); @@ -516,7 +519,8 @@ class CategoryViewer { global $wgBetterDirectionality, $wgTitle; if( $wgBetterDirectionality ) { $pageLang = $wgTitle->getPageLanguage(); - $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ); $list = Html::rawElement( 'div', $attribs, $list ); } diff --git a/includes/EditPage.php b/includes/EditPage.php index 108dfd6d51..f91cfda3cd 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2098,7 +2098,8 @@ HTML global $wgBetterDirectionality; if( $wgBetterDirectionality ) { $pageLang = $this->mTitle->getPageLanguage(); - $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); + $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ); $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML ); } wfProfileOut( __METHOD__ ); diff --git a/includes/ImagePage.php b/includes/ImagePage.php index b90043e312..8d50df6e13 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -117,7 +117,8 @@ class ImagePage extends Article { # but this section (the actual wikitext) should be in page content language $pageLang = $this->mTitle->getPageLanguage(); $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content', - 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ) ) ); + 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ) ) ); parent::view(); $wgOut->addHTML( Xml::closeElement( 'div' ) ); } else { diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 86d3172f6f..213d7008cb 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -462,7 +462,8 @@ class SkinTemplate extends Skin { in_array( $action, array( 'view', 'render', 'print' ) ) && ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) { $pageLang = $this->getTitle()->getPageLanguage(); - $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir() ); + $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), + 'class' => 'mw-content-'.$pageLang->getDir() ); $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext ); } } diff --git a/skins/common/shared.css b/skins/common/shared.css index f3f2bdea3c..c62a8ed561 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -62,7 +62,9 @@ div#mw-js-message { float: right; margin-left: 5px; } - +/* Correct directionality when page dir is different from site/user dir */ +/* @noflip */.mw-content-ltr .editsection, .mw-content-rtl [dir="ltr"] .editsection { float: right; } +/* @noflip */.mw-content-rtl .editsection, .mw-content-ltr [dir="rtl"] .editsection { float: left; } /** * File histories */ @@ -614,6 +616,18 @@ div.gallerytext { background-repeat: no-repeat; } +/* Correct directionality when page dir is different from site/user dir */ +/* @noflip */.mw-content-ltr ul, .mw-content-ltr ol, +.mw-content-rtl [dir="ltr"] ul, .mw-content-rtl [dir="ltr"] ol { + margin: .3em 0 0 1.5em; +} +/* @noflip */.mw-content-rtl ul, .mw-content-rtl ol, +.mw-content-ltr [dir="rtl"] ul, .mw-content-ltr [dir="rtl"] ol { + margin: .3em 1.5em 0 0; +} +/* @noflip */ { + margin: .3em 1.5em 0 0; +} /* Localised ordered list numbering for some languages */ ol:lang(bcc) li, ol:lang(bqi) li, @@ -640,6 +654,26 @@ ol:lang(or) li { list-style-type: oriya; } +/* Correct directionality when page dir is different from site/user dir */ +/* @noflip */.mw-content-ltr .toc ul, .mw-content-ltr #toc ul, +.mw-content-rtl [dir="ltr"] .toc ul, .mw-content-rtl [dir="ltr"] #toc ul { + text-align: left; + margin-left: 0; +} +/* @noflip */.mw-content-rtl .toc ul, .mw-content-rtl #toc ul, +.mw-content-ltr [dir="rtl"] .toc ul, .mw-content-ltr [dir="rtl"] #toc ul { + text-align: right; + margin-right: 0; +} +/* @noflip */.mw-content-ltr .toc ul ul, .mw-content-ltr #toc ul ul, +.mw-content-rtl [dir="ltr"] .toc ul ul, .mw-content-rtl [dir="ltr"] #toc ul ul { + margin: 0 0 0 2em; +} +/* @noflip */.mw-content-rtl .toc ul ul, .mw-content-rtl #toc ul ul, +.mw-content-ltr [dir="rtl"] .toc ul ul, .mw-content-ltr [dir="rtl"] #toc ul ul { + margin: 0 2em 0 0; +} + /* tooltip styles */ .mw-help-field-hint { display: none; @@ -737,3 +771,7 @@ th.headerSortDown { direction: ltr !important; unicode-bidi: embed; } + +#mw-revision-info, #mw-revision-nav { + direction: ltr; +} \ No newline at end of file -- 2.20.1